% Bubble sorting with a sorting network for 8 elements

function [numSwaps] = hw8BubbleSort(unsortedList)
[row, elem] = size(unsortedList);
numSwaps = 0;
% bubble sorting a 'semi' sorted array. to find points to penalize
for k = 1:elem-1
   for j = 1:elem-k
    if(unsortedList(j)> unsortedList(j+1))
     temp = unsortedList(j);
     unsortedList(j) = unsortedList(j+1);
     unsortedList(j+1) = temp;
     numSwaps = numSwaps + 1;
    end % if
   end % for
 end % for

